package com.jh3502.vivo.function.contact;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.TextView;

import com.jh3502.vivo.R;
import com.jh3502.vivo.base.BaseActivity;
import com.jh3502.vivo.base.BasePresenter;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author harisucici
 * @version 2018/11/27 07:53
 * name
 * todo
 * @email harisucici@gmail.com
 */
public class ContactDetailActivity extends BaseActivity {
    @BindView(R.id.toolbar_title)
    TextView toolbarTitle;
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.contact_detail_name)
    TextView contactDetailName;
    @BindView(R.id.contact_detail_job)
    TextView contactDetailJob;
    @BindView(R.id.contact_detail_dep)
    TextView contactDetailDep;
    @BindView(R.id.contact_detail_job_2)
    TextView contactDetailJob2;
    @BindView(R.id.contact_detail_phone)
    TextView contactDetailPhone;
    @BindView(R.id.contact_detail_mobile)
    TextView contactDetailMobile;
    private Bundle bundle;

    @Override
    public BasePresenter initPresenter() {
        return null;
    }

    @Override
    protected int setViewId() {
        return R.layout.activity_contact_detail;
    }

    @Override
    protected void initView() {
        bundle = getIntent().getExtras();
        toolbar.setTitle("");
        toolbarTitle.setText(bundle.getString("name"));
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        contactDetailDep.setText(bundle.getString("dep"));
        contactDetailName.setText(bundle.getString("name"));
        contactDetailJob.setText(bundle.getString("postname"));
        contactDetailJob2.setText(bundle.getString("postname"));
        contactDetailPhone.setText(bundle.getString("telephone"));
        contactDetailMobile.setText(bundle.getString("mobile"));
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                onBackPressed();
                break;
            default:
        }
        return true;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void doOnDestroy() {

    }

    @Override
    protected void doOnResume() {

    }

    @Override
    protected void doOnSaveInstanceState(Bundle savedInstanceState) {

    }

    @Override
    public void responseError(int code, String msg) {

    }

    @OnClick(R.id.contact_detail_phone)
    public void onContactDetailPhoneClicked() {
        Intent intent = new Intent(Intent.ACTION_DIAL);
        intent.setData(Uri.parse("tel:" + bundle.getString("telephone")));
        startActivity(intent);
    }

    @OnClick(R.id.contact_detail_mobile)
    public void onContactDetailMobileClicked() {
        Intent intent = new Intent(Intent.ACTION_DIAL);
        intent.setData(Uri.parse("tel:" + bundle.getString("mobile")));
        startActivity(intent);
    }
}
